﻿using System.Collections.Generic;
using System.Data;
namespace WPFExcelReport
{
    public partial class VMEVAR
    {

        public void Insert(DataRow _dwAPK)
        { 
            InsertMEVAR(_dwAPK);
            TBMain.Rows.InsertAt(_dwAPK, 0);
        }
        public void DELAE05(Dictionary<string, object> pm)
        {
            dwData = TBMain.NewRow();
            dwData["MEVMANDANT"] = app.Mandant;
            dwData["MEVMNRKRS"] = pm["MEKMNRKRS"];
            dwData["MEVMLFDNR"] = pm["MEKMLFDNR"];
            dwData["MEVMPOS"] = pm["MEKMPOS"];
            dwData["MEVAGANG"] = pm["MEKAGANG"];
            dwData["MEVMTYP"] = pm["MEKMTYP"];
            dwData["MEVEVARHNR"] = pm["MEKEVARHNR"];
            dwData["MEVEVARUNR"] = pm["MEKEVARUNR"];
            DMER02(dwData);
        }
        public DataSet LOADAE05(Dictionary<string, object> pm)
        {  
            dwData = TBMain.NewRow();
            dwData["MEVMANDANT"] = app.Mandant;
            dwData["MEVMNRKRS"] = " AND MEVMNRKRS='" + (string)pm["MNRKRS"]+"'";
            dwData["MEVMLFDNR"] = " AND MEVMLFDNR='" + (string)pm["MLFDNR"] + "'";
            dwData["MEVMPOS"] = " AND MEVMPOS='" + (string)pm["MPOS"] + "'";
            dwData["MEVMTYP"] = " AND MEVMTYP='" + (string) pm["MTYP"] + "'";
            dwData["MEVAGANG"] = " AND MEVAGANG='" + (string)pm["AGANG"] + "'";
            dwData["MEVEVARHNR"] = " AND MEVEVARHNR='" + (string)pm["EVARHNR"] + "'";
            dwData["MEVEVARUNR"] = " AND MEVEVARUNR='" + (string)pm["EVARUNR"] + "'";
            SResult = QMER02(dwData);
            return SResult;
        }
        public void NEWME05(Dictionary<string, object> pm)
        {
            TBMain.Clear();
            DataTable TBMod = (DataTable)pm["TBMOD"];
            string AGANG = (string)pm["AGANG"];
            string MTYP = (string)pm["MTYP"];
            string VARHNR = (string)pm["VARHNR"];
            string VARUNR = (string)pm["VARUNR"];
            foreach (DataRow dwAM06 in TBMod.Rows)
            {
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["MEVMANDANT"] = app.Mandant;
                dwData["MEVAGANG"] = AGANG;
                dwData["MEVMTYP"] = MTYP;
                dwData["MEVMNRKRS"] = (string)pm["KRS"];
                dwData["MEVMLFDNR"] = (string)pm["LFD"];
                dwData["MEVMPOS"]   = (string)pm["POS"];
                dwData["MEVEVARHNR"] = VARHNR;
                dwData["MEVEVARUNR"] = VARUNR;
                dwData["MEVMODNR"] = dwAM06["AMEMODNR"];
                dwData["MEVEINSTNR"] = dwAM06["AMEEINSTNR"];
                Insert(dwData);
            }
            TBMain.AcceptChanges();
        }
    }
    public partial class VMEVAR
    {
        public string MEVAGANG { get { if (dwMaster == null) return ""; return dwMaster["MEVAGANG"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVAGANG"] = value; OnPropertyChanged("MEVAGANG", value); } } //lENGth 15
        public string MEVMTYP { get { if (dwMaster == null) return ""; return dwMaster["MEVMTYP"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMTYP"] = value; OnPropertyChanged("MEVMTYP", value); } } //lENGth 8
        public string MEVMNRKRS { get { if (dwMaster == null) return ""; return dwMaster["MEVMNRKRS"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMNRKRS"] = value; OnPropertyChanged("MEVMNRKRS", value); } } //lENGth 2
        public string MEVMLFDNR { get { if (dwMaster == null) return ""; return dwMaster["MEVMLFDNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMLFDNR"] = value; OnPropertyChanged("MEVMLFDNR", value); } } //lENGth 4
        public string MEVMPOS { get { if (dwMaster == null) return ""; return dwMaster["MEVMPOS"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMPOS"] = value; OnPropertyChanged("MEVMPOS", value); } } //lENGth 2
        public string MEVEVARHNR { get { if (dwMaster == null) return ""; return dwMaster["MEVEVARHNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVEVARHNR"] = value; OnPropertyChanged("MEVEVARHNR", value); } } //lENGth 2
        public string MEVEVARUNR { get { if (dwMaster == null) return ""; return dwMaster["MEVEVARUNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVEVARUNR"] = value; OnPropertyChanged("MEVEVARUNR", value); } } //lENGth 2
        public string MEVMODNR { get { if (dwMaster == null) return ""; return dwMaster["MEVMODNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMODNR"] = value; OnPropertyChanged("MEVMODNR", value); } } //lENGth 3
        public string MEVEINSTNR { get { if (dwMaster == null) return ""; return dwMaster["MEVEINSTNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVEINSTNR"] = value; OnPropertyChanged("MEVEINSTNR", value); } } //lENGth 3
        public string MEVWERTX { get { if (dwMaster == null) return ""; return dwMaster["MEVWERTX"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVWERTX"] = value; OnPropertyChanged("MEVWERTX", value); } } //lENGth 16
        public string MEVWERTN { get { if (dwMaster == null) return ""; return dwMaster["MEVWERTN"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVWERTN"] = value; OnPropertyChanged("MEVWERTN", value); } } //lENGth 16

        #region======ColumnSchema==========
        /*
                 public string MEVMANDANT { get { if (dwMaster == null) return ""; return dwMaster["MEVMANDANT"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMANDANT"] = value; OnPropertyChanged("MEVMANDANT", value); } } //lENGth 2
                 public string MEVPROGNR { get { if (dwMaster == null) return ""; return dwMaster["MEVPROGNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVPROGNR"] = value; OnPropertyChanged("MEVPROGNR", value); } } //lENGth 4
                 public string MEVEINAUS { get { if (dwMaster == null) return ""; return dwMaster["MEVEINAUS"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVEINAUS"] = value; OnPropertyChanged("MEVEINAUS", value); } } //lENGth 1
                 public string MEVREZEPTNR { get { if (dwMaster == null) return ""; return dwMaster["MEVREZEPTNR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVREZEPTNR"] = value; OnPropertyChanged("MEVREZEPTNR", value); } } //lENGth 10
                 public string MEVREZEPTKZ { get { if (dwMaster == null) return ""; return dwMaster["MEVREZEPTKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVREZEPTKZ"] = value; OnPropertyChanged("MEVREZEPTKZ", value); } } //lENGth 1
                 public string MEVREZEPTST { get { if (dwMaster == null) return ""; return dwMaster["MEVREZEPTST"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVREZEPTST"] = value; OnPropertyChanged("MEVREZEPTST", value); } } //lENGth 1
                 public string MEVWERKZ { get { if (dwMaster == null) return ""; return dwMaster["MEVWERKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVWERKZ"] = value; OnPropertyChanged("MEVWERKZ", value); } } //lENGth 14
                 public string MEVFAKTOR { get { if (dwMaster == null) return ""; return dwMaster["MEVFAKTOR"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVFAKTOR"] = value; OnPropertyChanged("MEVFAKTOR", value); } } //lENGth 2
                 public string MEVSTAKZ { get { if (dwMaster == null) return ""; return dwMaster["MEVSTAKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVSTAKZ"] = value; OnPropertyChanged("MEVSTAKZ", value); } } //lENGth 1
                 public string MEVMODEIN { get { if (dwMaster == null) return ""; return dwMaster["MEVMODEIN"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVMODEIN"] = value; OnPropertyChanged("MEVMODEIN", value); } } //lENGth 1
                 public double MEVAENDZL { get { if (dwMaster == null) return 0.0; return  Convert.ToDouble(dwMaster["MEVAENDZL"].ToString()); } set { if (dwMaster == null) return; dwMaster["MEVAENDZL"] = value; OnPropertyChanged("MEVAENDZL", value); } } //lENGth 0
                 public string MEVAENDBEN { get { if (dwMaster == null) return ""; return dwMaster["MEVAENDBEN"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVAENDBEN"] = value; OnPropertyChanged("MEVAENDBEN", value); } } //lENGth 8
                 public double MEVAENDDAT { get { if (dwMaster == null) return 0.0; return  Convert.ToDouble(dwMaster["MEVAENDDAT"].ToString()); } set { if (dwMaster == null) return; dwMaster["MEVAENDDAT"] = value; OnPropertyChanged("MEVAENDDAT", value); } } //lENGth 0
                 public string MEVNEUBEN { get { if (dwMaster == null) return ""; return dwMaster["MEVNEUBEN"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVNEUBEN"] = value; OnPropertyChanged("MEVNEUBEN", value); } } //lENGth 8
                 public double MEVNEUDAT { get { if (dwMaster == null) return 0.0; return  Convert.ToDouble(dwMaster["MEVNEUDAT"].ToString()); } set { if (dwMaster == null) return; dwMaster["MEVNEUDAT"] = value; OnPropertyChanged("MEVNEUDAT", value); } } //lENGth 0
                 public string MEVFILLER { get { if (dwMaster == null) return ""; return dwMaster["MEVFILLER"].ToString(); } set { if (dwMaster == null) return; dwMaster["MEVFILLER"] = value; OnPropertyChanged("MEVFILLER", value); } } //lENGth 16
        */
        #endregion
    }
} 

